using System.IO;
using System.Reflection;
using System.Windows.Markup;

namespace System.Windows.Controls
{
    internal static class ResourceHelper
    {
        public static T GetXamlResource<T>(string pathToResource) where T : class
        {
            using (var resStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(pathToResource))
            {
                return resStream == null ? null : (T)XamlReader.Load(new StreamReader(resStream).ReadToEnd());
            }
        }
    }
}